
<h1>日期格式化</h1>
<script src="./utils.js"></script>
<script>
    console.log(dateFormat('2021-7-26 11:29:21'));
</script>

<hr>

<h1>判断浏览器内核类型</h1>
<script src="./utils.js"></script>
<script>
    console.log(num)
</script>

<hr>

<h1>判断是不是移动端</h1>
<script src="./utils.js"></script>


<hr>

<h1>判断是不是微信浏览器</h1>
<script src="./utils.js"></script>


<hr>


<img class="lazy" src-real="https://img2.baidu.com/it/u=2689033008,1831603944&fm=26&fmt=auto"
src="./img1.gif" width="640" height="480" alt="">
<hr>
<img class="lazy" src-real="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fi0.hdslb.com%2Fbfs%2Farticle%2F7b26f58e50f799e63cb5cc3bbe30beaa1657ff51.jpg&refer=http%3A%2F%2Fi0.hdslb.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1640867667&t=2468415222cc081271455f6334cef66c"
src="./img1.gif" width="640" height="480" alt="">
<hr>
<img class="lazy" src-real="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fbbsfiles.vivo.com.cn%2Fvivobbs%2Fattachment%2Fforum%2F201908%2F29%2F105307mluasswdeekeaul0.jpg&refer=http%3A%2F%2Fbbsfiles.vivo.com.cn&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1640867667&t=ca5f3ee5c1c388de2f732424eaee7b3d"
src="./img1.gif" width="640" height="480" alt="">
<hr>
<img class="lazy" src-real="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.zcool.cn%2Fcommunity%2F01cbb65d9ef982a8012060beebcd96.jpg%401280w_1l_2o_100sh.jpg&refer=http%3A%2F%2Fimg.zcool.cn&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1640867667&t=27cbedd5677a4bac32afd77f597ea655"
src="./img1.gif" width="640" height="480" alt="">
<hr>
<img class="lazy" src-real="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg17.3lian.com%2F201612%2F12%2F63416d346d60ab766d9c10228b2a4e7d.jpg&refer=http%3A%2F%2Fimg17.3lian.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1640867669&t=8b4b549c112b223cac1757eb509bfef7"
src="./img1.gif" width="640" height="480" alt="">
<hr>
<img src-real="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fclubimg.club.vmall.com%2Fdata%2Fattachment%2Fforum%2F201907%2F31%2F010515qxczyldtgqioowtn.jpg&refer=http%3A%2F%2Fclubimg.club.vmall.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1640867669&t=c8dca114b9ccd397585d86ce08dd389f" 
src="./img1.gif"width="640" height="480" alt="">
<script src="./lazyload.js"></script>


<hr>


<h1>仿json内置API，parse方法</h1>
<script src="./json.js"></script>

<hr>

<h1>仿json内置API，stringify方法</h1>
<script src="./json.js"></script>

<hr>


<h1>封装Get方法</h1>
<h1>百度一下，你就知道</h1>
<input type="text">
<button>百度一下</button>
<ul></ul>
<script src="./ajax.js"></script>
<script>
    let btnObj = document.querySelector('button')
    btnObj.onclick = function(){
        let a = document.querySelector('input').value
        get('http://www.baidu.com/sugrec',`prod=pc&wd=${a}`,res=>{ if(res&&res.g){
                        document.querySelector('ul').innerHTML = ``
                        res.g.forEach(item=>{
                            let liObj = document.createElement('li')
                            liObj.innerText = item.q
                            document.querySelector('ul').appendChild(liObj)
                        })
                    } else {
                        document.querySelector('ul').innerHTML = `<li>未找到数据</li>`
                    }})
    }
</script>

<hr>

<h1>最新电影</h1>
<button>点击搜一下</button>
<ul></ul>
<script src="./ajax1.js"></script> 
<script>
let btnObj = document.querySelector('button')
btnObj.onclick = function() {
    get(
        'https://m.maizuo.com/gateway',
        'cityId=310100&pageNum=1&pageSize=10&type=1&k=3576785',
        (res)=>{
            let ulObj = document.querySelector('ul')
            ulObj.innerText = ''
            if (!Array.isArray(res.data.films)) return 
            res.data.films.forEach(item => {
                    let liObj = document.createElement('li')
                    liObj.innerHTML = `${item.filmId} - ${item.name}<img src="${item.poster}" />`
                    ulObj.appendChild(liObj)
                })},
        (xhr)=>{
        xhr.setRequestHeader('X-Client-Info', '{"a":"3000","ch":"1002","v":"5.0.4","e":"1640005088441707321622529","bc":"310100"}')
        xhr.setRequestHeader('X-Host', 'mall.film-ticket.film.list')
        xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest')
        })
}
</script


<hr>


<h1>封装Promise</h1>
<h1>百度一下，你就知道</h1>
<input type="text">
<button>百度一下</button>
<ul></ul>
<script src="./axios.js"></script>
<script>
    let btnObj = document.querySelector('button')
    let ulObj = document.querySelector('ul')
    btnObj.onclick = function(){
        let a = document.querySelector('input').value
        get('http://www.baidu.com/sugrec',`prod=pc&wd=${a}`,)
    .then(
        res=>{
            if(res.g&&res){
                ulObj.innerHTML = ``
                res.g.forEach(item=>{
                    let liObj = document.createElement('li')
                    liObj.innerText = item.q
                    ulObj.appendChild(liObj)
                })
            } else {
                ulObj.innerHTML = `<li>未找到数据</li>`
            }
        },
        err=>{
            console.log(err)
        }
    )
    }
</script>